#include "ChessboardView.hpp"
#include "CellWidget.hpp"


ChessboardView::ChessboardView()
{	
	try
	{
		unsigned int i, j;
		
		for (i = 0 ; i < 8 ; i++)
		{
			for (j = 0 ; j < 8 ; j++)
				w_cells[i][j] = new CellWidget(Chess::getInstance()->getChessboard()->getCell(Position(i, j, Chess::WHITE)));
		}
	}
	catch(Exception* e)
	{	throw e;	}
}

void ChessboardView::refresh()
{}

ChessboardView::~ChessboardView()
{
	try
	{
		unsigned int i, j;
		
		for (i = 0 ; i < 8 ; i++)
		{
			for (j = 0 ; j < 8 ; j++)
				w_cells[i][j]->del();
		}
	}
	catch(Exception* e)
	{	throw e;	}
}


CellWidget*	ChessboardView::getCellWidget(const Position& pos) const
{	return (w_cells[pos.getRealX()][pos.getRealY()]);	}
